<%@ Control %>
<script language="c#" runat="server">
private Boolean m_Secure = false;
public String WelcomeMessage = "Welcome";
void Login_Click(Object sender, EventArgs e){
if (UsernameValidator.IsValid && PasswordValidator.IsValid){
UnsecurePanel.Visible = false;
Message.Text = WelcomeMessage + ", " + UserName.Text;
SecurePanel.Visible = true;
m_Secure = true;
}
}
void Logout_Click(Object sender, EventArgs e){
if (UsernameValidator.IsValid && PasswordValidator.IsValid){
Logoff();
}
}
public Boolean Secure{
get{
return m_Secure;
}
}
public String User{
get{
return UserName.Text;
}
}
public void Logoff(){
UnsecurePanel.Visible = true;
UserName.Text = "";
Password.Text = "";
SecurePanel.Visible = false;
m_Secure = false;
}
</script>
<asp:panel id="UnsecurePanel" runat="Server">
<asp:label runat="server" font-size="9pt">Username: </asp:label><br><asp:textbox id="UserName" runat="server" /><br>
<asp:requiredfieldvalidator id="UsernameValidator" runat="server" controltovalidate="UserName" errormessage="Please enter a username" style="color: red; font-size: 8pt" /><br>
<asp:label runat="server" font-size="9pt">Password: </asp:label><br><asp:textbox id="Password" runat="server" textmode="Password" /><br>
<asp:requiredfieldvalidator id="PasswordValidator" runat="server" controltovalidate="Password" errormessage="Please enter a password" style="color: red; font-size: 8pt" /><br>
<asp:button id="Login" text="Login" runat="server" onclick="Login_Click"/>
</asp:panel>
<asp:panel id="SecurePanel" runat="Server" visible="false">
<asp:label id="Message" runat="server"/><br>
<asp:linkbutton id="Logout" runat="server" onclick="Logout_Click" text="Logout" style="font-size: 8pt; color: blue;"/>
</asp:panel>